<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="x-ua-compatible" content="ie=edge">

  <title>MediSys | CCTA 分析报告</title>

  <!-- Font Awesome Icons -->
  <link rel="stylesheet" href="/plugins/fontawesome-free/css/all.min.css">
  <!-- IonIcons -->
  <link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="/dist/css/adminlte.min.css">
  <!-- Google Font: Source Sans Pro -->
  <link href="/dist/css/google_fonts_source_sans_pro.css" rel="stylesheet">
</head>
<!--
BODY TAG OPTIONS:
=================
Apply one or more of the following classes to to the body tag
to get the desired effect
|---------------------------------------------------------|
|LAYOUT OPTIONS | sidebar-collapse                        |
|               | sidebar-mini                            |
|---------------------------------------------------------|
-->
<body class="hold-transition sidebar-mini sidebar-collapse">
<div class="wrapper">
  <!-- Navbar -->
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
      </li>
    </ul>


    <!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
      <li class="nav-item">
        <a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#"><i
            class="fas fa-th-large"></i></a>
      </li>
    </ul>
  </nav>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
  <aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="/" class="brand-link">
      <img src="/dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
           style="opacity: .8">
      <span class="brand-text font-weight-heavy"><b>Medi-</b>Sys</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
      <!-- Sidebar user panel (optional) -->
      <div class="user-panel mt-3 pb-3 mb-3 d-flex">
        <div class="image">
          <img src="/dist/img/avatar3.png" class="img-circle elevation-2" alt="User Image">
        </div>
        <div class="info">
          <a href="#" class="d-block">User</a>
        </div>
      </div>

      <!-- Sidebar Menu -->
      <nav class="mt-2">
        <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
        </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
    </section>

    <!-- Main content -->
    <div class="content container-fluid">
      <span id="mycontent"></span>

      <div class="row">
        <div class="col-sm-12">
          <div class="card card-primary">
            <div class="card-header with-border">
              <h3 class="card-title">冠脉3D重建</h3>
              <div class="card-tools">
                <button type="button" class="btn btn-tool card-auto-collapse" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
                <button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fas fa-times"></i></button>
              </div>
            </div>
            <div id="ccta3d" class="card-body chart-responsive">
                <iframe id="ccta3diframe" src="" height="700px" width="100%"></iframe>
            </div>
          </div>
        </div>
      </div>

      <div class="row">
        <div class="col-sm-12">
          <div class="card card-primary">
            <div class="card-header with-border">
              <h3 class="card-title">前降支参数</h3>
              <div class="card-tools">
                <button type="button" class="btn btn-tool card-auto-collapse" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
              </div>
            </div>

            <div class="card-body chart-responsive">
              <div class="row">
                <div id="lad_1" class="col-sm-6" style="height: 300px;"></div>
                <div id="lad_2" class="col-sm-6" style="height: 300px;"></div>
              </div>
{{/*              <div class="row">*/}}
{{/*                <div class="col-sm-6">*/}}
{{/*                  <div id="chart_lad_1_legend" class="legend"></div>*/}}
{{/*                  <br />*/}}
{{/*                  <div id="chart_lad_1" style="height:300px"></div>*/}}
{{/*                </div>*/}}
{{/*                <div class="col-sm-6">*/}}
{{/*                  <div id="chart_lad_2_legend" class="legend"></div>*/}}
{{/*                  <br />*/}}
{{/*                  <div id="chart_lad_2" style="height:300px"></div>*/}}
{{/*                </div>*/}}
{{/*              </div>*/}}

            </div>
          </div>
        </div>
      </div>

      <div class="row">
        <div class="col-sm-12">
          <div class="card card-primary">
            <div class="card-header with-border">
              <h3 class="card-title">回旋支参数</h3>
              <div class="card-tools">
                <button type="button" class="btn btn-tool card-auto-collapse" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
              </div>
            </div>

            <div class="card-body chart-responsive">
              <div class="row">
                <div id="lcx_1" class="col-sm-6" style="height: 300px;"></div>
                <div id="lcx_2" class="col-sm-6" style="height: 300px;"></div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="row">
        <div class="col-sm-12">
          <div class="card card-primary">
            <div class="card-header with-border">
              <h3 class="card-title">右冠脉参数</h3>
              <div class="card-tools">
                <button type="button" class="btn btn-tool card-auto-collapse" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
              </div>
            </div>

            <div class="card-body chart-responsive">
              <div class="row">
                <div id="rca_1" class="col-sm-6" style="height: 300px;"></div>
                <div id="rca_2" class="col-sm-6" style="height: 300px;"></div>
            </div>
          </div>
        </div>
      </div>
      </div>
    </div>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->

  <!-- Main Footer -->
  <footer class="main-footer">
  </footer>
</div>
<!-- ./wrapper -->

<!-- REQUIRED SCRIPTS -->
<!-- jQuery -->
<script src="/plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI -->
<script src="/plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Bootstrap -->
<script src="/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/plugins/jquery-mousewheel/jquery.mousewheel.js"></script>
<!-- FLOT CHARTS -->
<script src="/plugins/flot/jquery.flot.js"></script>
<!-- FLOT RESIZE PLUGIN - allows the chart to redraw when the window is resized -->
<!--<script src="/plugins/flot-old/jquery.flot.resize.min.js"></script>-->
<script src="/plugins/flot/plugins/jquery.flot.resize.js"></script>
<!-- AdminLTE -->
<script src="/dist/js/adminlte.js"></script>

<script src="/plugins-custom/pako/pako.min.js"></script>
<script src="/webapp/common/js/uiCommon.js"></script>
<script src="/webapp/js/tools.js"></script>
{{/*<script src="/webapp/ai/analysis/js/mychart.js"></script>*/}}

<script>
  let ccta_outputdir="/webapp/temp/ccta/json/";

  class plot {
    id
    ref;
    data;
    tip;
    timer;

    constructor(id) {
      this.id = id
      this.ref = $(`#${id}`);
      this.tips = $(`<div class="tooltip-inner" id="${this.id}-tooltip"></div>`).css({
        position: 'absolute',
        display: 'none',
        opacity: 0.8
      }).appendTo('body')

      this.data = []
    }

    insert(data, name, color) {
      this.data.push({
        data: data,
        color: color,
        label: name
      })

    }

    insertLine(data,name,color) {
      let tmp = []
      for (let i=0;i<data.length;i++) {
        tmp.push([i,data[i]])
      }
      this.insert(tmp,name,color)
    }

    show() {
      $.plot(this.ref, this.data, {
        grid: {
          hoverable: true,
          borderColor: '#f3f3f3',
          borderWidth: 1,
          tickColor: '#f3f3f3'
        },
        series: {
          shadowSize: 0,
          lines: {
            show: true
          },
          points: {
            show: false
          }
        },
        lines: {
          fill: false,
          color: ['#3c8dbc', '#f56954']
        },
        yaxis: {
          show: true
        },
        xaxis: {
          show: true
        }
      })
      //Initialize tooltip on hover

      this.ref.bind('plothover', (event, pos, item) => {
        if (item) {
          let x = item.datapoint[0].toFixed(2),
                  y = item.datapoint[1].toFixed(2)

          this.tips.html(item.series.label + ` ${x}, ${y}`)
                  .css({
                    top: item.pageY + 5,
                    left: item.pageX + 5
                  })
                  .fadeIn(200)
          clearTimeout(this.timer)
          this.timer = setTimeout(()=> {
            this.tips.hide()
          },2000)
        } else {
          this.tips.hide()
        }
      })
    }
  }

  let u = analysisURL(window.location.href)
  let pipe = u['pipe']

  $.get(`/api/v1/ai/ct/ccta/algo1/${pipe}`).fail(function(resp){
    console.log("F",resp)
  }).done((resp)=> {
    // show 3d model
    let u = `analysis?type=deepbuild&mode=ccta3d&pipe=${pipe}`
    console.log("ccta3d",u)
    $("#ccta3diframe").attr("src",u)

    let data=JSON.parse(unGzip(resp.data))

    let lad1 = new plot("lad_1")
    lad1.insertLine(JSON.parse(data.lad_ctmax), "max")
    lad1.insertLine(JSON.parse(data.lad_ctmin), "min")
    lad1.insertLine(JSON.parse(data.lad_ctavg), "avg")
    lad1.show()

    let lad2 = new plot("lad_2")
    lad2.insertLine(JSON.parse(data.lad_max), "R_max")
    lad2.insertLine(JSON.parse(data.lad_min), "R_min")
    lad2.show()

    let lcx1 = new plot("lcx_1")
    lcx1.insertLine(JSON.parse(data.lcx_ctmax), "max")
    lcx1.insertLine(JSON.parse(data.lcx_ctmin), "min")
    lcx1.insertLine(JSON.parse(data.lcx_ctavg), "avg")
    lcx1.show()

    let lcx2 = new plot("lcx_2")
    lcx2.insertLine(JSON.parse(data.lcx_max), "R_max")
    lcx2.insertLine(JSON.parse(data.lcx_min), "R_min")
    lcx2.show()

    let rca1 = new plot("rca_1")
    rca1.insertLine(JSON.parse(data.rca_ctmax), "max")
    rca1.insertLine(JSON.parse(data.rca_ctmin), "min")
    rca1.insertLine(JSON.parse(data.rca_ctavg), "avg")
    rca1.show()
    let rca2 = new plot("rca_2")
    rca2.insertLine(JSON.parse(data.rca_max), "R_max")
    rca2.insertLine(JSON.parse(data.rca_min), "R_min")
    rca2.show()

    let lm1 = new plot("lm_1")
    lm1.insertLine(JSON.parse(data.lm_ctmax), "max")
    lm1.insertLine(JSON.parse(data.lm_ctmin), "min")
    lm1.insertLine(JSON.parse(data.lm_ctavg), "avg")
    lm1.show()
    let lm2 = new plot("lm_2")
    lm2.insertLine(JSON.parse(data.lm_max), "R_max")
    lm2.insertLine(JSON.parse(data.lm_min), "R_min")
    lm2.show()

  })

  // var line_data1 = {
  //   data : sin,
  //   color: '#3c8dbc'
  // }
  // var line_data2 = {
  //   data : cos,
  //   color: '#00c0ef'
  // }
</script>

<script>
  setTimeout('closeCard3D()',300);
  function closeCard3D(){
    $('.card-auto-collapse').click()
    $('.legendLayer .background').css("fill","none")
  }
</script>

</body>
</html>
